package c1703;

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.Arrays;
import java.util.StringTokenizer;
 
public class F {
    static QuickInput cin = new QuickInput();
    static PrintWriter cout = new PrintWriter(System.out);
 
    public static void main(String[] args) {
 
        int n = cin.nextInt();
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = cin.nextInt();
        }
        Arrays.sort(a);
        int[] dp = new int[a.length];
        dp[0] = 1;
        for (int i = 1; i < n; i++) {
            if (a[i] == a[i - 1]) dp[i] = dp[i - 1] + 1;
            else dp[i] = 1;
        }
        int best = a[0], max = dp[0];
        for (int i = 1; i < dp.length; i++) {
            if (dp[i] > max) {
                best = a[i];
                max = dp[i];
            }
        }
        cout.println(best);
        cout.println(max);
        cout.close();
    }
 
    static class QuickInput {
        BufferedReader buf;
        StringTokenizer tok;
 
        QuickInput() {
            buf = new BufferedReader(new InputStreamReader(System.in));
        }
 
        boolean hasNext() {
            while (tok == null || !tok.hasMoreElements()) {
                try {
                    tok = new StringTokenizer(buf.readLine());
                } catch (Exception e) {
                    return false;
                }
            }
            return true;
        }
 
        String next() {
            if (hasNext()) return tok.nextToken();
            return null;
        }
 
        int nextInt() {
            return Integer.parseInt(next());
        }
 
        long nextLong() {
            return Long.parseLong(next());
        }
 
        double nextDouble() {
            return Double.parseDouble(next());
        }
 
        BigInteger nextBigInteger() {
            return new BigInteger(next());
        }
 
        BigDecimal nextBigDecimal() {
            return new BigDecimal(next());
        }
    }
}